new Vue({
    el: '#app',
    data: {
        username: '',
        password: ''
    },
    methods: {
        async btnRegister() {
            if (this.username === '' || this.password === '') {
                show('用户名或密码不能为空!')
                return
            }

            if (this.username.length < 8 || this.username.length > 30 || this.password.length < 6 || this.password.length > 30) {
                show('用户名长度要求8-30个字符 密码长度要求6-30个字符')
                return
            }

            try {
                const res = await axios.post('/register', { username: this.username, password: this.password })

                show(res.message)
                setTimeout(e => {
                    location.href = './login.html'
                }, 1500)
            } catch (error) {
                show('未知错误 请联系管理员')
            }

        }
    }
})